package zzxkj.blog.controller;

import org.modelmapper.ModelMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import zzxkj.blog.cacheService.EchartsDataService;
import zzxkj.blog.dao.BlogDao;
import zzxkj.blog.dto.TotalCountOfAll;

import java.util.List;
/**
 * 统计数据
 * @author zzxkj
 */
@RestController
public class CountDataController {
    private final EchartsDataService dataService;
    private final BlogDao blogDao;

    public CountDataController(EchartsDataService dataService, BlogDao blogDao) {
        this.dataService = dataService;
        this.blogDao = blogDao;
    }

    @PostMapping("/charts_views")
    public List<Object> getDayViewsData(Model model){
        List<Object> data = dataService.getChartViewData();
        return data;
    }
    @PostMapping("/charts_comments")
    public List<Object> getDayCommentsData(Model model){
        List<Object> data = dataService.getChartCommentsData();
        return data;
    }

    @PostMapping("/charts_total_count")
    public TotalCountOfAll getTotalCountOfAll(Model model){
        TotalCountOfAll totalCountOfAll = blogDao.getTotalCountOfAll();
        return totalCountOfAll;
    }
}
